package com.customer.util;

import com.customer.model.ResponseStatus;
import lombok.Data;

/**
 * 2 * @Author: xy
 * 3 * @Date: 2021/10/14 下午 7:29:06
 */
@Data
public class ResponseData {
    private int code;
    private String msg;
    private Object data;

    public ResponseData(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static ResponseData success(Object data) {
        return new ResponseData(ResponseStatus.SUCCESS.getCode(), ResponseStatus.SUCCESS.getMessage(), data);
    }

    public static ResponseData success() {
        return new ResponseData(ResponseStatus.SUCCESS.getCode(), ResponseStatus.SUCCESS.getMessage(), null);
    }

    public static ResponseData fail() {
        return new ResponseData(ResponseStatus.FAIL.getCode(), ResponseStatus.FAIL.getMessage(), null);

    }

    public static ResponseData fail(Object data) {
        return new ResponseData(ResponseStatus.FAIL.getCode(), ResponseStatus.FAIL.getMessage(), data);
    }
}
